#include <memory> 
#include <iostream> 

struct Widget { 
    int m_number; 
};

struct MyClass { 
    std::unique_ptr<Widget> m_p; 
    MyClass()
    :m_p(new Widget{})
    {

    }
    MyClass(Widget w):m_p(new Widget{w}){

    }
    MyClass(const MyClass& rhs)
    :m_p(new Widget(*rhs.m_p))
    {

    }

    MyClass& operator=(const MyClass& rhs)
    {
        if(this != &rhs){
            std::unique_ptr<Widget> temp{new Widget(*rhs.m_p)}; 
            m_p.swap(temp);
        }

        return *this;
    }

    MyClass(MyClass&& rhs) noexcept = default;
    MyClass& operator=(MyClass&& rhs) noexcept = default;
    ~MyClass() noexcept = default;

};

int main()
{
    MyClass a{Widget{42}};
    MyClass b{a};
    b = a;
    std::cout << (*a.m_p).m_number << std::endl;
    std::cout << (*b.m_p).m_number << std::endl;
    return 0;
}